package io.cici.cc.mybatis.lite.sql_source.scripting.tag;


import io.cici.cc.mybatis.lite.sql_source.Context;
import io.cici.cc.mybatis.lite.sql_source.scripting.ognl.Ognl;

/**
 * @author huihui
 */
public class BindTag implements Tag {

    private final String name;
    private final String expression;

    public BindTag(String name, String expression) {
        this.name = name;
        this.expression = expression;
    }

    @Override
    public boolean apply(Context context) {
        final Object value = Ognl.getValue(context.getBindings(), expression);
        context.bind(name, value);
        return true;
    }

}
